home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq21.zip / MBBS.SLT < prev    next >
Text File  |  1992-03-20  |  12KB  |  336 lines

  1. //-----------------------------------------------------------
  2. // MBBS.SL? Automatic logging into an MBBS system.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs, BEFORE you use it. Then recompile with CS MBBS.
  6. //-----------------------------------------------------------
  7.  
  8. // If you have suggestions for improving this script, please suggest
  9. // improvements to me via old-fashioned snail-mail to:
  10.  
  11. // Author:  Inge Vabekk
  12. //          Hamangskogen 108
  13. //          N-1300 SANDVIKA
  14. //          NORWAY
  15. //          tel. (472) 546 396
  16.  
  17. str thisBBStype[] = "MBBS"   // This BBS type.      
  18.    ,line     [80]            // General help line.
  19.    ,codename  [8]            // Code name for this BBS.
  20.    ,myprot    [2]            // Chosen protocol.
  21.    ,hisprot   [2]            // MBBS's translation.
  22.    ,mypass   [24]            // My password
  23.  
  24.                              // For the Global storage:
  25.    ,global   []="GLOBAL"     // Global script.
  26.    ,PutLine  []="PUTLINE"    // PutLine script
  27.    ,bbstype  []="BTYPE"      // BBS type
  28.    ,short    []="SHORT"      // Short BBS name
  29.    ,code     []="CNAME"      // Code name for this BBS
  30.    ,hprot    []="HPROT"      // MBBS's interpretation of protocol
  31.    ,prompt   []="PROMPT"     // Current prompt (global name)
  32.    ,mscript  []="MDOOR"      // Name of mail door
  33.    ,passw    []="PASSW"      // Current password
  34.    ,mailup   []="MAILUP"     // Name of upload mail script
  35.    ,command[10]              // Current prompt (value)
  36.    ;     
  37.  
  38. int y=4                          // Y coordinate for messages
  39.    ,tol = 300                    // No activity for 30 seconds
  40.    ,t1, t2, t3, t4, t5, t6, t7   // makes script time out. 
  41.    ,pw1                          // Tracks new password request
  42.    ,stat, tmark
  43.    ,messages                     // Messages to fetch?
  44.    ,fixup='0'                    // '1' if setup should be fixed
  45.    ,Enter = 13
  46.    ;
  47.  
  48. //-----------------------------------------------------------   
  49. // Script starts here.
  50. //-----------------------------------------------------------   
  51.  
  52. main(int ppass)
  53. {
  54. int filter
  55.    ,i, j, k, l
  56.    ,mo 
  57.    ,dlfile
  58.    ,status
  59.    ;
  60.  
  61.   entry();                             // Updates colors & status bar. 
  62.  
  63. // Only if online.
  64.  
  65.   if (!carrier())  
  66.   { failtone();
  67.     status_wind ("T²: THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  68.     return (-1);
  69.   }
  70.  
  71.   read (bbstype,line);                 // Get current BBS type.
  72.   if (line != thisBBStype)  
  73.   { wrongBBS();                        // Doesn't match script!
  74.     return (-1);
  75.   }
  76.  
  77. // Start tracking.
  78.           
  79.   status = 1;     
  80.   t1 = track ("Command:",0);             // Track command.
  81.   t2 = track ("Kommando",0);             // Norwegian.
  82.   t3 = track ("? for menu)",0);          // Command (non-expert)
  83.   t4 = track ("Status:",0);              // System status.
  84.   mo = track ("--more--", 0);           
  85.   pw1  = track ("will echo)",0);         // Password not accepted?
  86.  
  87.   read (passw,mypass);
  88.   if (ppass)                             // Write password?
  89.   { cputs (mypass);                      // Can't use PutLine here!
  90.     cputc (Enter);
  91.     delay(1);
  92.     cputs ("^K");                        // Cut some of the crap.
  93.   }
  94.   tmark = timer_start (tol);             // Wait a minute for login
  95.  
  96.   while ((stat=trig()) > 0)              // Check for files to download.
  97.   { if (stat == t1)                      // Command?
  98.       break;                             // So proceed.
  99.  
  100.     else if (stat == t2)                 // Norwegian command???
  101.       english();                         // Redefine to English.
  102.  
  103.     else if (stat == t3)                 // Non-expert?
  104.     { call (PutLine, "U X S", Enter);    // Tell him I'm a SuperExpert!
  105.       track_free(stat);                  // Release this tracking.
  106.     }
  107.     else if (stat == t4)                 // System status?
  108.       status = 0;
  109.     else if (stat == pw1)                // New password request?
  110.     { cputs (mypass);                    // Send password. Remember we
  111.       cputc (Enter);                     // can't use PutLine here!!!!
  112.     }
  113.     else if (stat == mo)                 // MORE? Just stop this for now.
  114.       call (PutLine, "N", Enter);
  115.   }
  116.   release();                             // Release tracks and timer.
  117.   if (!carrier()) return (-1);
  118.  
  119.   terminal();                            // Update screen.
  120.   i = j = gety();                        // All lines on screen:
  121.   while (i >= 0)
  122.   { vgetchrs(0,--i,line,0,60);           // Get the line.
  123.     setchr (line,60,0);
  124.     if (strposi(line,"private file(s)",0) > 0) 
  125.     { read (short,line);                 // Get short BBS name.
  126.       strcat (line,".DL");               // Add DL extension.
  127.       dlfile = fopen (line,"a");         // Try open <BBS>.DL
  128.       for (++i; i<j; ++i)
  129.       { vgetchrs(0,i,line,0,60);         // Get the filename.
  130.         setchr (line,60,0);              // Write three lines
  131.         if (trim(line) <= 0) break;      // Return if line empty.
  132.         fputs (line,dlfile);             // Write line to file.
  133.         fputs ("^M^J",dlfile);
  134.       }
  135.       fclose(dlfile);                  // Close .dl file.
  136.       i = -1;                          // Done.
  137.     }
  138.   }
  139.  
  140.   line = "CHAT N;";                    // No chat.
  141.   if (status) strcat (line,"W;");      // Who's on?
  142.   strcat (line,"U L 0;T ");            // Continuous output.
  143.   read (hprot,hisprot);                // Make sure protocol is
  144.   strcat (line,hisprot);               // whatever defined in
  145.   call (PutLine, line, Enter);         // the phone directory. Get
  146.                                        // list of who's on.
  147.   command = "Command:";                // Set MBBS command prompt.
  148.   write (prompt,command);
  149.  
  150.   t1 = track (command,0);              // Use it for tracking.
  151.   t2 = track ("lter enabl",0);         // Filter still enabled?
  152.   t3 = track ("lter disab",0);         // Filter disabled?
  153.   tmark = timer_start (tol);           // Give me a minute.
  154.   filter = 1;
  155.  
  156.   while ((stat=trig()) > 0)            // Until filter is off:     
  157.   { if (stat==t1)                      // Command:
  158.     { if (!filter) break;              // Filter off?
  159.       flush();
  160.       cputc (222);                     // Write an ASCII 222 to the port.
  161.       filter=cgetct(3)!=222;           // Did it return unchanged?
  162.       cputc (8);                       // Delete the ASCII 222 w/ backspace.
  163.       if (!filter) break;              // Filter off now?
  164.       call (PutLine, "FILT", Enter);   // No, switch it off.
  165.     }
  166.     else if (stat == t2)
  167.       filter = 1;                      // Filter still on!
  168.     else if (stat == t3)
  169.       break;                           // No, it's off!
  170.   }
  171.   release();                           // Release tracks and timer.
  172.   if (!carrier()) return (-1);
  173.   write (mscript,mailup);              // Next script.
  174.   
  175.   read (fixup,line);                   // Fix setup?
  176.   if (subchr(line,0)=='1')
  177.   { cputs("M Y Y Y Y N Y;MF 40;AF Z;C^M");
  178.     t1 = track("ll be", 0);
  179.     t2 = track(command, 0);
  180.     tmark = timer_start (tol);         // Give me a minute.
  181.     while ((stat=trig()) > 0)          // Until conference list is set:
  182.     { if (stat == t1)
  183.         call (PutLine,"C",Enter);
  184.       else if (stat == t2)
  185.         break;
  186.     }
  187.     release();
  188.   }
  189.   if (!carrier()) return (-1);
  190.   
  191.   vgetchrs(0,gety(),line,0,80);        // Get last line on screen.
  192.   if (strpos (line,command,0) < 0)     // If it isn't a prompt,
  193.     waitfor (command,5);               // wait.
  194.  
  195.   return (0);                          // Return.
  196. }
  197.  
  198. //-----------------------------------------------------------
  199. // Wrong BBS type.
  200. //-----------------------------------------------------------
  201.  
  202. wrongBBS()
  203. {
  204. str help[48];
  205.  
  206.     failtone();                          // Alarm.    
  207.     help = "This script is for ";        // Catenate strings.
  208.     strcat (help,thisBBStype);
  209.     strcat (help," only!");
  210.     status_wind (help,20);               // Display message for 2 sec.
  211. }
  212.  
  213. //-----------------------------